const jsonwebtoken = require('jsonwebtoken');
const path = require("path");
const fs = require("fs");
const {toBase64} = require("js-base64");

let o = {
    name: 'GQQ'
}
const express = require('express')
let app = express()


let privateKey = fs.readFileSync(path.join('./private.key'))
let publicKey = fs.readFileSync(path.join('./public.pem'))

// console.log(r,'\n',publicKey)

app.get('/sign', (req, res) => {
    let r = jsonwebtoken.sign(o, privateKey, {
        algorithm: 'RS256',
        expiresIn: 1000 * 60,
    })
    res.send(r)
})
app.get('/verify', (req, res) => {
    let r = req.query.token
    let v = jsonwebtoken.verify(r, publicKey,{algorithms:["RS256"]})
    res.send(v)
})
app.listen(13145, () => {
    console.log('ok')
})




